package org.appmon.core.servlet;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.xml.parsers.ParserConfigurationException;

import org.appmon.core.agent.loader.PostJvmAgentLoader;
import org.appmon.core.config.XmlReader;
import org.xml.sax.SAXException;

public class ApplicationMonitoringServlet extends HttpServlet{

	private static final long serialVersionUID = -1109853135684732892L;

	
	public void init() throws ServletException
	  {
		
		//Agent loading		
		PostJvmAgentLoader.loadAgent();	
				
	    String xmlConfigLocation=getServletConfig().getInitParameter("appmon-config");
		xmlConfigLocation = getServletConfig().getServletContext().getRealPath(xmlConfigLocation);
		XmlReader xmlReader=new XmlReader();
		try {
			xmlReader.getXmlConfig(xmlConfigLocation);
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
		} catch (SAXException e) {
			 e.printStackTrace();
		} catch (IOException e) {
			 e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
				
		System.out.println("FullPath  : "+xmlConfigLocation);
		
		

		
	  }


	

}
